package com.wuhongyu.controller;

import com.wuhongyu.service.CustomerService;
import com.wuhongyu.service.OrdersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;


/**
 * 订单...订单只有查询
 */
@Controller
@RequestMapping("/orders")
public class OrdersController {

    @Autowired
    private OrdersService ordersService;
    @Autowired
    private CustomerService customerService;

    @RequestMapping("/list")
    public String list(Model model, Integer customerid){
        model.addAttribute("ordersList",ordersService.findAll(customerid));
        model.addAttribute("customer",customerService.findOne(customerid));
        return "~cust/cust/orders";
    }

    @RequestMapping("/query")
    public String query(Model model, Integer id){
        model.addAttribute("orders",ordersService.findOne(id));
        return "~cust/cust/orders_detail";
    }
}